<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%
String basePath = request.getContextPath();
%>
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>改约</title>
		<link rel="stylesheet" href="<%=basePath %>/css/style.css" type="text/css" />
		<script type="text/javascript" src="<%=basePath %>/js/My97DatePicker/WdatePicker.js"></script>
		<script type='text/javascript' src='<%=basePath %>/js/jquery1.3.2/js/jquery-1.3.2.min.js'></script>
		<script type='text/javascript' src='<%=basePath %>/js/jquery1.3.2/js/jquery.form.js'></script>
	</head>

	<body>
		<div id="rollbar">
			<div>
				<label accesskey="e"></label><s:actionerror/>
				<div class="tabcontainer">
					<form id="form" name="form" method="post" action="<%=basePath %>/order/saveReservation.do">
						<input type="hidden" name="orderId" value="<s:property value="reservation.idOrder"/>"/>
						<input type="hidden" name="groupOrderId" value="<s:property value="reservation.idGroupOrder"/>"/>
						<input type="hidden" name="reservation.id" value="<s:property value="reservation.id"/>"/>
						<table id="edittable" style="width:700px;">
							<tr>
								<td colspan="4" class="column_head" style="font-size:14px;font-weight:bold;">
									订单信息
								</td>
							</tr>
							<tr>
								<td class="column_name" style="width:15%">
									订单号
								</td>
								<td class="column_input" style="width:35%">
									<s:property value="reservation.orderNo"/>
								</td>
								<td class="column_name" style="width:15%">
									订单来源
								</td>
								<td class="column_input" style="width:35%">
									<s:property value="orderInfo.orderFrom"/>
								</td>
							</tr>
							<tr>
								<td class="column_name">
									购买人
								</td>
								<td class="column_input">
									<s:property value="reservation.buyUser"/>
								</td>
								<td class="column_name">
									有效期
								</td>
								<td class="column_input">
									<s:date name="orderInfo.startDate" format="yyyy-MM-dd"/>至<s:date name="orderInfo.endDate" format="yyyy-MM-dd"/>
								</td>
							</tr>
							<tr>
								<td class="column_name">
									邮寄地址
								</td>
								<td class="column_input">
									<s:property value="reservation.address"/>
								</td>
								<td class="column_name">
									邮政编码
								</td>
								<td class="column_input" >
									<s:property value="reservation.postcode"/>
								</td>
							</tr>
							<tr>
								<td class="column_name">
									体检人姓名
								</td>
								<td class="column_input">
									<s:property value="reservation.tijian"/>
								</td>
								<td class="column_name">
									性别
								</td>
								<td class="column_input">
									<s:property value="reservation.sex"/>
								</td>
							</tr>
							<tr>
								<td class="column_name">
									年龄
								</td>
								<td class="column_input">
									<s:property value="reservation.age"/>
								</td>
								<td class="column_name">
									身份证号
								</td>
								<td class="column_input">
									<s:property value="reservation.idcard"/>
								</td>
							</tr>
							<tr>
								<td class="column_name">
									电话号码
								</td>
								<td class="column_input">
									<input type="text" name="reservation.phone" id="phone"
										value="<s:if test="reservation.phone!=null"><s:property value="reservation.phone"/></s:if>" size="25" maxlength="40"/>
								</td>
								<td class="column_name">
									手机
								</td>
								<td class="column_input">
									<input type="text" name="reservation.mobile" id="mobile"
										value="<s:if test="reservation.mobile!=null"><s:property value="reservation.mobile"/></s:if>" size="25" maxlength="40"/>
								</td>
							</tr>
						</table>
						<table id="edittable" style="width:700px;">
							<tr>
								<td colspan="4" class="column_head" style="font-size:14px;font-weight:bold;">
									预约信息
								</td>
							</tr>
							<tr>
								<td class="column_name" style="width:15%">
									合作机构
								</td>
								<td class="column_input" style="width:35%">
									<s:property value="reservation.institutionName"/>
									<input type="hidden" id="institutionId" value="<s:property value="reservation.idInstitution"/>"/>
								</td>
								<td class="column_name" style="width:15%">
									套餐名称
								</td>
								<td class="column_input" style="width:35%">
									<s:property value="reservation.productName"/>
									<input type="hidden" id="productId" name="productId" value="<s:property value="reservation.productId"/>"/>
								</td>
							</tr>
							<tr>
								<td class="column_name">
									成交价格
								</td>
								<td class="column_input">
									<s:property value="reservation.salePrice"/>
								</td>
								<td class="column_name">
									优惠价格
								</td>
								<td class="column_input">
									<s:property value="reservation.productPrice"/>
								</td>
							</tr>
							<tr>
								<td class="column_name">
									预约日期
								</td>
								<td class="column_input">
									<input type="text" name="reservation.reserveDate" id="reserveDate"
										value="<s:date name="reservation.reserveDate" format="yyyy-MM-dd"/>"
										size="25" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true})" />
									<!-- input type="button" value="营业时间" onclick="showWorkTime()" style="width:60px;"/> -->
								</td>
								<td class="column_name">
									预约分院
								</td>
								<td class="column_input">
									<s:if test="institutionBranchList != null && institutionBranchList.size()>0">
										<s:select list="institutionBranchList" name="reservation.branch" id="branch" listKey="name" listValue="name" headerKey="-1" headerValue="请选择分院"></s:select>
									</s:if>
									<s:else>
									<input type="text" name="reservation.branch"
										value="<s:property value="reservation.branch"/>" size="25" maxlength="20"/>
									</s:else>
								</td>
							</tr>
							<tr>
								<td class="column_name">
									预约备注
								</td>
								<td class="column_input" colspan="3">
									<input type="text" name="reservation.comments"
										value="<s:property value="reservation.comments"/>" size="84" maxlength="100"/>
								</td>
							</tr>
							<tr>
								<td class="column_name">
									订单客服备注
								</td>
								<td class="column_input" colspan="3">
									<input type="text" name="orderInfo.comment"
										value="<s:property value="orderInfo.comment"/>" size="86" maxlength="100"/>
								</td>
							</tr>
							<tr>
								<td colspan="4" class="column_bottom">
									<input name="submit" type="button" onclick="saveReservation()" value="提交" />
									<input name="reset" type="reset" id="reset" value="重置" />
								</td>
							</tr>
						</table>
					</form>
				</div>

			</div>
		</div>
		<script language="javascript">
			function checkForm(){
    			var rd = document.getElementById("reserveDate");
    			if(rd.value==""){
    				rd.focus();
    				alert("请选择预约日期");
    				return false;
    			}
    			var phone = document.getElementById("phone");
				var mobile= document.getElementById("mobile");
    			if(phone.value=="" && mobile.value==""){
    				if(!confirm("没有输入联系方式，确认继续预约吗？")){
    					return false;
    				}
    			}
    			return true;
    		}
    		function saveReservation(){
    			if(checkForm()){
    				var options = {
						success:function(data){
							if(data.success){
								alert("预约成功！");
								try{
									window.parent.OrderInfoView.reloadData();
								}catch(e){};
								try{
									window.parent.ReservationView.reloadData();
								}catch(e){};
								//window.parent.win.close();
							}
						},
						dataType:"json"
					}; 
					$('#form').ajaxForm(options).submit();
    			}
    		}
		</script>
	</body>
</html>
